<template>
  <div class="product-name">
    <span>{{ name }}</span>
    <div class="icons">
      <svg-icon v-if="collectable" class="icon-class" :style="iconStyle" :icon-class="iconClass" @click.native.stop="clickHandle" />
      <img class="icon-share" src="@/assets/icon-share.png" @click.stop="clickShare">
    </div>
  </div>
</template>
<script>
export default {
  name: 'ProductName',
  props: {
    name: {
      type: String,
      default: ''
    },
    collectable: {
      type: Boolean,
      default: false
    },
    collected: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {

    }
  },
  computed: {
    iconClass() {
      return this.collected ? 'shoucang-solid' : 'shoucang-line'
    },
    iconStyle() {
      return this.collected ? { color: '#00C8B4' } : ''
    }
  },
  methods: {
    clickHandle() {
      this.collected ? this.$emit('cancel-collect') : this.$emit('collect')
    },
    clickShare() {
      this.$emit('share')
    }
  }
}
</script>
<style lang="less" scoped>
.product-name{
  display: flex;
  justify-content: space-between;
  // align-items: center;
  // height: 22px;
  line-height: 22px;
  padding: 10px 0;
  &>span{
    color: #333;
    font-size: 16px;
    font-weight: 700;
  }
  .icons{
    margin-left: 10px;
    height: 22px;
    display: flex;
    align-items: center;
  }
  .icon-class{
    font-size: 20px;
    color: #888;
  }
  .icon-share{
    width: 19px;
    height: auto;
    margin-left: 10px;
  }
}
</style>
